VERSION 5.00
Begin VB.UserControl BarCode39Ctrl 
   ClientHeight    =   540
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   2235
   ScaleHeight     =   540
   ScaleWidth      =   2235
   Begin VB.Label Label1 
      Caption         =   "Bar Code 39 Control"
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   1575
   End
End
Attribute VB_Name = "BarCode39Ctrl"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Dim x, y As Integer
Dim w As Integer
Dim m As Integer
Dim Pat(19, 16) As Boolean
Dim LocalBarString As String
Dim LocalBarHeight As Integer

Private Sub UserControl_Initialize()

   w = 20 'width of each narrow bar/space
   
   Pat(1, 1) = True
   Pat(1, 2) = True
   Pat(1, 3) = True
   Pat(1, 4) = False
   Pat(1, 5) = True
   Pat(1, 6) = False
   Pat(1, 7) = False
   Pat(1, 8) = False
   Pat(1, 9) = True
   Pat(1, 10) = False
   Pat(1, 11) = True
   Pat(1, 12) = False
   Pat(1, 13) = True
   Pat(1, 14) = True
   Pat(1, 15) = True

   Pat(2, 1) = True
   Pat(2, 2) = False
   Pat(2, 3) = True
   Pat(2, 4) = True
   Pat(2, 5) = True
   Pat(2, 6) = False
   Pat(2, 7) = False
   Pat(2, 8) = False
   Pat(2, 9) = True
   Pat(2, 10) = False
   Pat(2, 11) = True
   Pat(2, 12) = False
   Pat(2, 13) = True
   Pat(2, 14) = True
   Pat(2, 15) = True

   Pat(3, 1) = True
   Pat(3, 2) = True
   Pat(3, 3) = True
   Pat(3, 4) = False
   Pat(3, 5) = True
   Pat(3, 6) = True
   Pat(3, 7) = True
   Pat(3, 8) = False
   Pat(3, 9) = False
   Pat(3, 10) = False
   Pat(3, 11) = True
   Pat(3, 12) = False
   Pat(3, 13) = True
   Pat(3, 14) = False
   Pat(3, 15) = True

   Pat(4, 1) = True
   Pat(4, 2) = False
   Pat(4, 3) = True
   Pat(4, 4) = False
   Pat(4, 5) = False
   Pat(4, 6) = False
   Pat(4, 7) = True
   Pat(4, 8) = True
   Pat(4, 9) = True
   Pat(4, 10) = False
   Pat(4, 11) = True
   Pat(4, 12) = False
   Pat(4, 13) = True
   Pat(4, 14) = True
   Pat(4, 15) = True

   Pat(5, 1) = True
   Pat(5, 2) = True
   Pat(5, 3) = True
   Pat(5, 4) = False
   Pat(5, 5) = True
   Pat(5, 6) = False
   Pat(5, 7) = False
   Pat(5, 8) = False
   Pat(5, 9) = True
   Pat(5, 10) = True
   Pat(5, 11) = True
   Pat(5, 12) = False
   Pat(5, 13) = True
   Pat(5, 14) = False
   Pat(5, 15) = True

   Pat(6, 1) = True
   Pat(6, 2) = False
   Pat(6, 3) = True
   Pat(6, 4) = True
   Pat(6, 5) = True
   Pat(6, 6) = False
   Pat(6, 7) = False
   Pat(6, 8) = False
   Pat(6, 9) = True
   Pat(6, 10) = True
   Pat(6, 11) = True
   Pat(6, 12) = False
   Pat(6, 13) = True
   Pat(6, 14) = False
   Pat(6, 15) = True

   Pat(7, 1) = True
   Pat(7, 2) = False
   Pat(7, 3) = True
   Pat(7, 4) = False
   Pat(7, 5) = False
   Pat(7, 6) = False
   Pat(7, 7) = True
   Pat(7, 8) = False
   Pat(7, 9) = True
   Pat(7, 10) = True
   Pat(7, 11) = True
   Pat(7, 12) = False
   Pat(7, 13) = True
   Pat(7, 14) = True
   Pat(7, 15) = True

   Pat(8, 1) = True
   Pat(8, 2) = True
   Pat(8, 3) = True
   Pat(8, 4) = False
   Pat(8, 5) = True
   Pat(8, 6) = False
   Pat(8, 7) = False
   Pat(8, 8) = False
   Pat(8, 9) = True
   Pat(8, 10) = False
   Pat(8, 11) = True
   Pat(8, 12) = True
   Pat(8, 13) = True
   Pat(8, 14) = False
   Pat(8, 15) = True

   Pat(9, 1) = True
   Pat(9, 2) = False
   Pat(9, 3) = True
   Pat(9, 4) = True
   Pat(9, 5) = True
   Pat(9, 6) = False
   Pat(9, 7) = False
   Pat(9, 8) = False
   Pat(9, 9) = True
   Pat(9, 10) = False
   Pat(9, 11) = True
   Pat(9, 12) = True
   Pat(9, 13) = True
   Pat(9, 14) = False
   Pat(9, 15) = True

   Pat(0, 1) = True
   Pat(0, 2) = False
   Pat(0, 3) = True
   Pat(0, 4) = False
   Pat(0, 5) = False
   Pat(0, 6) = False
   Pat(0, 7) = True
   Pat(0, 8) = True
   Pat(0, 9) = True
   Pat(0, 10) = False
   Pat(0, 11) = True
   Pat(0, 12) = True
   Pat(0, 13) = True
   Pat(0, 14) = False
   Pat(0, 15) = True
   
   'Star pattern
   Pat(10, 1) = True
   Pat(10, 2) = False
   Pat(10, 3) = False
   Pat(10, 4) = False
   Pat(10, 5) = True
   Pat(10, 6) = False
   Pat(10, 7) = True
   Pat(10, 8) = True
   Pat(10, 9) = True
   Pat(10, 10) = False
   Pat(10, 11) = True
   Pat(10, 12) = True
   Pat(10, 13) = True
   Pat(10, 14) = False
   Pat(10, 15) = True
   
   'Slash pattern
   Pat(11, 1) = True
   Pat(11, 2) = False
   Pat(11, 3) = False
   Pat(11, 4) = False
   Pat(11, 5) = True
   Pat(11, 6) = False
   Pat(11, 7) = False
   Pat(11, 8) = False
   Pat(11, 9) = True
   Pat(11, 10) = False
   Pat(11, 11) = True
   Pat(11, 12) = False
   Pat(11, 13) = False
   Pat(11, 14) = False
   Pat(11, 15) = True
   
   'P pattern
   Pat(12, 1) = True
   Pat(12, 2) = False
   Pat(12, 3) = True
   Pat(12, 4) = True
   Pat(12, 5) = True
   Pat(12, 6) = False
   Pat(12, 7) = True
   Pat(12, 8) = True
   Pat(12, 9) = True
   Pat(12, 10) = False
   Pat(12, 11) = True
   Pat(12, 12) = False
   Pat(12, 13) = False
   Pat(12, 14) = False
   Pat(12, 15) = True
   
   'A pattern
   Pat(13, 1) = True
   Pat(13, 2) = True
   Pat(13, 3) = True
      Pat(13, 4) = False
   Pat(13, 5) = True
      Pat(13, 6) = False
   Pat(13, 7) = True
      Pat(13, 8) = False
      Pat(13, 9) = False
      Pat(13, 10) = False
   Pat(13, 11) = True
      Pat(13, 12) = False
   Pat(13, 13) = True
   Pat(13, 14) = True
   Pat(13, 15) = True
   
   'B pattern
   Pat(14, 1) = True
      Pat(14, 2) = False
   Pat(14, 3) = True
   Pat(14, 4) = True
   Pat(14, 5) = True
      Pat(14, 6) = False
   Pat(14, 7) = True
      Pat(14, 8) = False
      Pat(14, 9) = False
      Pat(14, 10) = False
   Pat(14, 11) = True
      Pat(14, 12) = False
   Pat(14, 13) = True
   Pat(14, 14) = True
   Pat(14, 15) = True
   
   'C pattern
   Pat(15, 1) = True
   Pat(15, 2) = True
   Pat(15, 3) = True
      Pat(15, 4) = False
   Pat(15, 5) = True
   Pat(15, 6) = True
   Pat(15, 7) = True
      Pat(15, 8) = False
   Pat(15, 9) = True
      Pat(15, 10) = False
      Pat(15, 11) = False
      Pat(15, 12) = False
   Pat(15, 13) = True
      Pat(15, 14) = False
   Pat(15, 15) = True
   
   'D pattern
   Pat(16, 1) = True
      Pat(16, 2) = False
   Pat(16, 3) = True
      Pat(16, 4) = False
   Pat(16, 5) = True
   Pat(16, 6) = True
   Pat(16, 7) = True
      Pat(16, 8) = False
      Pat(16, 9) = False
      Pat(16, 10) = False
   Pat(16, 11) = True
      Pat(16, 12) = False
   Pat(16, 13) = True
   Pat(16, 14) = True
   Pat(16, 15) = True
   
   'E pattern
   Pat(17, 1) = True
   Pat(17, 2) = True
   Pat(17, 3) = True
      Pat(17, 4) = False
   Pat(17, 5) = True
      Pat(17, 6) = False
   Pat(17, 7) = True
   Pat(17, 8) = True
   Pat(17, 9) = True
      Pat(17, 10) = False
      Pat(17, 11) = False
      Pat(17, 12) = False
   Pat(17, 13) = True
      Pat(17, 14) = False
   Pat(17, 15) = True
   
   'F pattern
   Pat(18, 1) = True
      Pat(18, 2) = False
   Pat(18, 3) = True
   Pat(18, 4) = True
   Pat(18, 5) = True
      Pat(18, 6) = False
   Pat(18, 7) = True
   Pat(18, 8) = True
   Pat(18, 9) = True
      Pat(18, 10) = False
      Pat(18, 11) = False
      Pat(18, 12) = False
   Pat(18, 13) = True
      Pat(18, 14) = False
   Pat(18, 15) = True
   
   '- pattern
   Pat(19, 1) = True
      Pat(19, 2) = False
      Pat(19, 3) = False
      Pat(19, 4) = False
   Pat(19, 5) = True
      Pat(19, 6) = False
   Pat(19, 7) = True
      Pat(19, 8) = False
   Pat(19, 9) = True
   Pat(19, 10) = True
   Pat(19, 11) = True
      Pat(19, 12) = False
   Pat(19, 13) = True
   Pat(19, 14) = True
   Pat(19, 15) = True
   
End Sub

Public Sub PrintBarCode()
   Dim letter As String
   Dim Idx As Integer
   
   Printer.DrawWidth = 1
   Printer.DrawStyle = vbSolid
   
   For I = 1 To Len(LocalBarString)
      letter = Mid(LocalBarString, I, 1)
      Select Case letter
         Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
            Idx = Val(letter)
         Case "*"
            Idx = 10
         Case "/"
            Idx = 11
         Case "P"
            Idx = 12
         Case "A"
            Idx = 13
         Case "B"
            Idx = 14
         Case "C"
            Idx = 15
         Case "D"
            Idx = 16
         Case "E"
            Idx = 17
         Case "F"
            Idx = 18
         Case "-"
            Idx = 19
      End Select
      
      If I <> 1 Then
         x = x + w 'intercharacter gap
      End If
      
      For J = 1 To 15
         If Pat(Idx, J) = True Then
            For k = 0 To w - 1
               Printer.Line (x + k, y)-Step(0, LocalBarHeight)
            Next k
         End If
         x = x + w
      Next J
      
   Next I
End Sub

Property Let BarString(ByVal bs As String)
   LocalBarString = "*" & bs & "*"
End Property

Property Let BarHeight(ByVal bh As Integer)
   LocalBarHeight = bh
End Property

Property Let StartX(ByVal sx As Integer)
   x = sx
End Property

Property Let StartY(ByVal sy As Integer)
   y = sy
End Property
